package ua.cn.stu.broker;

import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import ua.cn.stu.task.Task;

public class Broker extends UnicastRemoteObject implements ICompute {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5313171255060867440L;

	protected Broker() throws RemoteException {
		super();
	}

	public Object executeTask(Task t) {
		return t.executeTask();
	}

	public static void main(String[] args) {
		System.setProperty("java.security.policy", "D:\\rmi.policy");
		if (System.getSecurityManager() == null) {
			System.setSecurityManager(new RMISecurityManager());
		}
		String name = "rmi://localhost/Broker";
		try {
			LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
			ICompute engine = new Broker();
			Naming.rebind(name, engine);
			System.out.println("Broker bound");
		} catch (Exception e) {
			System.err.println("Broker exception: " + e.getMessage());
			e.printStackTrace();
		}
	}
	
	/*for(Address element: m1){
		
	}*/

}
